﻿// -------------------------------------------------------------------------
//    @FileName         :    NFSignInMonthPart.cpp
//    @Author           :    gaoyi
//    @Date             :    24-8-30
//    @Email            :    445267987@qq.com
//    @Module           :    NFSignInMonthPart
//
// -------------------------------------------------------------------------

#include "NFSignInMonthPart.h"

#include <NFComm/NFCore/NFTimeUtility.h>

#include "proto_cs_login.pb.h"
#include "proto_db.pb.h"

NFSignInMonthPart::NFSignInMonthPart()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NFSignInMonthPart::~NFSignInMonthPart()
{
}

int NFSignInMonthPart::CreateInit()
{
    return 0;
}
    
int NFSignInMonthPart::ResumeInit()
{
    return 0;
}

int NFSignInMonthPart::LoadFromDB(const proto_ff::tbRoleDetail *pDBData)
{
    m_stData.FromPb(pDBData->role_play_data().sign_in_monthly_data());
    return 0;
}

int NFSignInMonthPart::InitConfig(proto_ff::tbRoleDetail *pDbData, const RoleOne &stRoleOne)
{
    CHECK_NULL(0, pDbData);
    auto pSignData = pDbData->mutable_role_play_data()->mutable_sign_in_monthly_data();
    uint32_t now = NF_ADJUST_TIMENOW();
    int year;
    int month;
    int day;
    NFTimeUtility::GetCurDate(now, year, month, day);

    pSignData->set_can_sign(true);
    pSignData->set_already_sign_times(0);
    pSignData->set_already_pay_sign_times(0);
    pSignData->set_max_pay_sign_times(0);
    pSignData->set_max_sign_times(NFTimeUtility::GetCurMonthDay(year, month));

    /*if (CDescUtil::GetDescStoreSignInMonthAward()->AccuNum() <= MAX_ACCUMULATE_SIZE)
        for (int i = 0; i < CDescUtil::GetDescStoreSignInMonthAward()->AccuNum(); i++)
        {
            pSignData->add_sign_state(proto_ff::EN_SIGN_STATE_CANNOT_SIGN);
        }
    else LOGSVR_ERROR("signinmonthly accunum is out of range.");*/
    return 0;
}

int NFSignInMonthPart::SaveDB(proto_ff::tbRoleDetail *pDBData)
{
    m_stData.ToPb(pDBData->mutable_role_play_data()->mutable_sign_in_monthly_data());
    return 0;
}

int NFSignInMonthPart::MakePlayerDataCS(proto_ff::Proto_CSGetRoleRsp* pCSGetRoleRsp)
{
    m_stData.ToPb(pCSGetRoleRsp->mutable_sign_in_monthly_data());
    return 0;
}

int NFSignInMonthPart::MakeCityPlayerData(proto_ff::CityRoleInfo* pGCCityRoleInfo)
{
    return 0;
}
